<template>
  <div>
    <template v-for="(item, index) in options">
      <template v-if="values.includes(item.value)">
        <span
            v-if="item.elTagType == 'default' || item.elTagType == ''"
            :key="item.value"
            :index="index"
            :class="item.elTagType"
        >{{ item.label }}</span>
        <el-tag
            v-else
            :disable-transitions="true"
            :key="item.value + ''"
            :index="index"
            :type="item.elTagType === 'primary' ? '' : item.elTagType"
            :class="item.elTagType"
        >{{ item.label }}
        </el-tag>
      </template>

    </template>

    <template v-if="viewVal">
      {{ spValue }}
    </template>
  </div>
</template>

<script setup>
import {isVoid} from "../../utils/util";

const {proxy} = getCurrentInstance();
const spValue = ref('');
const props = defineProps({
  // 数据
  options: {
    type: Array,
    default: [],
  },
  spVal: [Number, String, Array],
  // 当前的值
  value: [Number, String, Array],
})
const viewVal = computed(() => {
  if (props.spVal !== null && typeof props.spVal !== 'undefined') {
    spValue.value = '*';
  }
  let view = true;
  for (var i = 0, len = props.options.length; i < len; i++) {
    if (proxy.lsh.eq(props.options[i].value, values.value[0])) {
      view = false;
      break;
    }
  }
  return view;
})

const values = computed(() => {
  if (props.value !== null && typeof props.value !== 'undefined') {
    return Array.isArray(props.value) ? props.value : [String(props.value)];
  } else {
    return [];
  }
})

</script>

<style scoped>
.el-tag + .el-tag {
  margin-left: 10px;
}
</style>
